<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '推广统计详情页';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="channel-visit-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [

            [
                'attribute'=>'utm',
                'label' => '渠道链接',
                'format' => ['raw',],
                'content' => function($model){
                    return 'www.lonlife.mobi/?s='.$model['utm'];
                }
            ],

            [
                'attribute'=>'channel.note',
                'label' => '备注',
            ],

            [
                'attribute'=>'jump',
                'label' => '从cn跳转',
            ],

            [
                'attribute'=>'visit',
                'label' => '访问量',
            ],

            [
                'attribute'=>'down',
                'label' => '下载量',
            ],

            [
                'attribute'=>'conversion',
                'label' => '转化率',
                'format' => ['raw',],
                'content' => function($model){
                    $conv =  $model['visit'] ? $model['down']*100/$model['visit'] : 0;
                    return $conv.'%';
                }
            ],

        ],
    ]); ?>
</div>
